-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpasswordExample.js
35 lines (26 loc) · 1003 Bytes
/
passwordExample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// The trusted root ca of the appliance
const caFile = '';
// The appliance host name or IP address
const hostName = '';
// The user name for password authentication
const userName = '';
// The password for password authentication
const password = '';
const SafeguardJs = require('../../src/safeguard');
(async () => {
try {
SafeguardJs.addCAFromFile(caFile);
console.log('Logging in', '\n');
let connection = await SafeguardJs.connectPassword(hostName, userName, password);
console.log('Getting me');
let result = await connection.invoke(SafeguardJs.Services.CORE, SafeguardJs.HttpMethods.GET, 'v4/Me');
console.log(result, '\n');
console.log('Getting login time remaining');
result = await connection.getAccessTokenLifetimeRemaining();
console.log(`Time remaining: ${result}`, '\n');
console.log('Logging out');
await connection.logout();
} catch (e) {
console.log(e);
}
})();